﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NullTextInput
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.textEdit1.EditValueChanged += new EventHandler(textEdit1_EditValueChanged);
            RefreshColor();
        }

        void textEdit1_EditValueChanged(object sender, EventArgs e)
        {
            RefreshColor();
        }

        private void RefreshColor()
        {
            textEdit1.CustomDisplayText += new DevExpress.XtraEditors.Controls.CustomDisplayTextEventHandler(textEdit1_CustomDisplayText);
            if (textEdit1.EditValue != null)
            {
                //textEdit1.ForeColor = this.ForeColor;
            }
            else
            {
                //textEdit1.ForeColor = Color.Gray;
            }
        }

        void textEdit1_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
        {
            if (textEdit1.EditValue != null)
            {
                textEdit1.Properties.NullText = "please input";
                textEdit1.Properties.NullValuePrompt = "jinggao shushu";
                textEdit1.ForeColor = this.ForeColor;
            }
            else
            {
                textEdit1.ForeColor = Color.Gray;
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            this.textEdit1.Enabled = false;
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            textEdit1.Enabled = true;
        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            textEdit1.Properties.NullValuePromptShowForEmptyValue = false;
        }
    }
}
